<cfsilent><!---

CF_Kalendar

COPYRIGHT & LICENSING INFO
-------------------------------------------------------------------

Copyright 2006 TJ Downes - tdownes@sanative.net - http://www.sanative.net

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

--->

<!--- attributes.view - defines which display mode to show: day, week, weeklist, month, condensed --->
<cfparam name="Attributes.view" type="string" default="list" />
<!--- attributes.rsCategories - a recordset of categories to populate the category select box --->
<cfparam name="attributes.categoriesRS" type="query" />
<!--- attributes.categoryID - defines which category to pull in our recordset --->
<cfparam name="attributes.categoryID" type="numeric" default="0" />
<!--- attributes.linkDate - defines the starting date of our recordset --->
<cfparam name="Attributes.linkDate" type="date" default="#Now()#" />
<!--- attributes.eventRecords - an array of structs containing the recordset --->
<cfparam name="Attributes.eventRecords" type="array" default="0" />
<!--- attributes.ExcludeTimeHeader - boolean to specifiy if the header on the calendar for times is displayed --->
<cfparam name="Attributes.ExcludeTimeHeader" type="boolean" default="no" />
<!--- attributes.TooltipSubLength - the length to concatenate the Title string for the tooltips --->
<cfparam name="Attributes.TooltipSubLength" type="string" default="35" />
<!--- attributes.maxDescriptionSize - the length to concatenate the Description string for the tooltips --->
<cfparam name="Attributes.maxDescriptionSize" type="numeric" default="150" />
<!--- attributes.calendarLinkPage - the page that the user is taken to when they click an event --->
<cfparam name="Attributes.calendarLinkPage" type="string" default="" />
<!--- attributes.urlAddString - a URL string to add to the calendarLinkPage attribute --->
<cfparam name="Attributes.urlAddString" type="string" default="" />
<!--- attributes.includeDetailsUnderMiniCalendar - boolean specifying if the details of events are to be included under the condensed view. --->
<cfparam name="Attributes.includeDetailsUnderMiniCalendar" default="0" />
<!--- attributes.UnderMiniCalendarIncludePath - allows a developer to include a file under the condensed view. --->
<cfparam name="Attributes.UnderMiniCalendarIncludePath" type="string" default="" />

<!--- set month variables to establish start and end of month --->
<cfscript>
	FirstDateOfMonth = Month(Attributes.linkDate) & "/1/" &  Year(Attributes.linkDate);
	FirstDateOfMonth = CreateODBCDate(FirstDateOfMonth);
	LastDateOfMonth = Month(Attributes.linkDate) & "/" & DaysInMonth(FirstDateOfMonth) & "/" &  Year(Attributes.linkDate);
	LastDateOfMonth = CreateODBCDate(LastDateOfMonth);
	DayOfWeekForFirstDateOfMonth = -DayOfWeek(FirstDateOfMonth) + 1;
	FirstDateOfWeek = CreateODBCDate(DateAdd('d', DayOfWeekForFirstDateOfMonth, FirstDateOfMonth));
	DayOfWeekForLastDateOfMonth = 7 - DayOfWeek(LastDateOfMonth);
	LastDateOfWeek = CreateODBCDate(DateAdd('d', DayOfWeekForLastDateOfMonth, LastDateOfMonth));
	FirstWeekOfMonth = Week(FirstDateOfMonth);
	LastWeekOfMonth = Week(LastDateOfMonth);
	eventRecords = Attributes.eventRecords;
</cfscript>
</cfsilent>
<a id="top"></a>
<table id="condensedDisplayMainTable">
<tr>
<td style="vertical-align: top;">
<!---- MINI CALENDAR DISPLAY ---->
<cfoutput>
<table class="miniCalendarTable">
<tr>
	<td colspan="7">
	<table style="border-collapse: collapse; padding: 0; margin: 0; width: 100%;">
	<tr>
		<td class="miniCalendarNav">
		<a href="#cgi.SCRIPT_NAME#?linkDate=#DateFormat(DateAdd("m", -1, attributes.linkDate), "mm/dd/yyyy")#&amp;view=list&amp;categoryID=#attributes.categoryID#" title="#DateFormat(DateAdd("m", -1, attributes.linkDate), "mmm yyyy")#">&lt;&lt;</a></td>
		<td class="miniCalendarNav" style="width: 50%">
		<strong>#DateFormat(Attributes.LinkDate, "mmmm yyyy")#</strong></td>
		<td class="miniCalendarNav">
		<a href="#cgi.SCRIPT_NAME#?linkDate=#DateFormat(DateAdd("m", 1, attributes.linkDate), "mm/dd/yyyy")#&amp;view=list&amp;categoryID=#attributes.categoryID#" title="#DateFormat(DateAdd("m", 1, attributes.linkDate), "mmm yyyy")#&categoryID=#attributes.categoryID#">&gt;&gt;</a></td>
	</tr>
	</table>
	</td>
</tr>
<tr>
	<td class="eventDayName">Su</td>
	<td class="eventDayName">Mo</td>
	<td class="eventDayName">Tu</td>
	<td class="eventDayName">We</td>
	<td class="eventDayName">Th</td>
	<td class="eventDayName">Fr</td>
	<td class="eventDayName">Sa</td>
</tr>
</cfoutput>
<cfloop index="LoopWeek" from="#FirstWeekOfMonth#" to="#LastWeekOfMonth#">
<tr>
	<cfloop index="LoopIndex" from="0" to="6">
	<cfset EventExists = 0 />
	<td class="eventDayHeader">
	<cfsilent>
	<cfloop index="i" from="1" to="#ArrayLen(attributes.eventRecords)#">
		<cfif CreateODBCDate(eventRecords[i].StartDate) lte CreateODBCDate(DateAdd('d', LoopIndex, FirstDateOfWeek))>
			<cfif CreateODBCDate(eventRecords[i].EndDate) gte CreateODBCDate(DateAdd('d', LoopIndex, FirstDateOfWeek))>
				<cfset EventExists = 1 />
			</cfif>
		</cfif>
	</cfloop>
	</cfsilent>
	<cfoutput>
	<cfset thisDay = DateAdd('d', LoopIndex, FirstDateOfWeek) />
	<cfif Month(DateAdd('d', LoopIndex, FirstDateOfWeek)) eq Month(Attributes.LinkDate)><cfif EventExists><div class="miniCalendarDayClass"><a href="###Day(thisDay)#" class="calendardates2">#Day(thisDay)#</a></div><cfelse>#Day(DateAdd('d', LoopIndex, FirstDateOfWeek))#</cfif></cfif></cfoutput></td>
	</cfloop>
</tr>
<cfset FirstDateOfWeek = CreateODBCDate(DateAdd('d', 7, FirstDateOfWeek)) />
</cfloop>
</table><br />
<cfform method="post" action="#cgi.SCRIPT_NAME#" id="viewchange" class="allForms">
<div><input type="hidden" name="LinkDate" value="<cfoutput>#attributes.LinkDate#</cfoutput>" id="LinkDate" />
<input type="hidden" name="categoryID" value="<cfoutput>#attributes.categoryID#</cfoutput>" />
<select name="view" class="calendarSelectBoxes" onchange="document.getElementById('viewchange').submit();">
	<option value="day">day</option>
	<option value="week">week</option>
	<option value="weeklist">week list</option>
	<option value="month">month</option>
	<option value="list" selected="selected">condensed</option>
</select></div>
</cfform>
<cfform method="post" action="#cgi.script_name#" id="categoryChange" class="allForms">
<div><input type="hidden" name="linkdate" value="<cfoutput>#attributes.linkdate#</cfoutput>" id="linkdate" />
<input type="hidden" name="view" value="<cfoutput>#attributes.view#</cfoutput>" />
<select name="categoryID" class="calendarSelectBoxes" onchange="document.getElementById('categoryChange').submit();">
	<cfoutput query="attributes.categoriesRS">
	<option value="#categoryID#"<cfif attributes.categoryID eq categoryID> selected</cfif>>#left(categoryName, 25)#</option>
	</cfoutput>
	<option value="0"<cfif attributes.categoryID eq 0> selected</cfif>>all</option>	
</select></div></cfform>
<cfif Len(Trim(Attributes.UnderMiniCalendarIncludePath))><br />
	<cfinclude template="#Attributes.UnderMiniCalendarIncludePath#" />
</cfif>
</td>
<td style="width: 10px"></td>
<td style="vertical-align: top;">
	<cfif ArrayLen(attributes.eventRecords) neq 0>
	<table class="condensedList">
	<cfloop index="i" from="1" to="#ArrayLen(attributes.eventRecords)#">
	<cfif Month(eventRecords[i].StartDate) eq Month(Attributes.LinkDate) OR Month(eventRecords[i].EndDate) eq Month(Attributes.LinkDate)>
	<cfoutput>
	<tr class="eventListItem"<cfif application.KConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))> style="background-color: ###eventRecords[i].CategoryBGColor#;"</cfif>>
		<td style="width: 100px;"<cfif application.KConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#DateFormat(eventRecords[i].StartDate, "mmm dd")#<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate> - #DateFormat(eventRecords[i].EndDate, "mmm dd")#</cfif></td>
		<td><a href="###eventRecords[i].EventID#-id"<cfif application.KConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#eventRecords[i].Title#</a></td>
	</tr>
	</cfoutput>
	<tr>
	   <td colspan="2" class="condensedListSeperator">&nbsp;</td>
	</tr>
	</cfif>
	</cfloop>
	</table>
	</cfif>
	</td>
</tr>
</table>
<cfif attributes.includeDetailsUnderMiniCalendar>
<p />
<cfif ArrayLen(attributes.eventRecords) neq 0>
<table id="miniCalendarDetailTable">
<!--- Display Individual Events --->
<cfloop index="i" from="1" to="#ArrayLen(attributes.eventRecords)#">
	<cfif Month(eventRecords[i].StartDate) eq Month(Attributes.LinkDate) OR Month(eventRecords[i].EndDate) eq Month(Attributes.LinkDate)>
	<cfoutput>
	<tr>
		 <td valign="top"><a id="evid-#eventRecords[i].EventID#" style="display: none;"></a>
		<a id="#eventRecords[i].EventID#-id"></a>#DateFormat(eventRecords[i].StartDate, "dddd, mmmm dd")#<cfif len(trim(eventRecords[i].StartTime))> #TimeFormat(eventRecords[i].StartTime, 'h:mm tt')#</cfif><cfif eventRecords[i].StartDate neq eventRecords[i].EndDate> - #DateFormat(eventRecords[i].EndDate, "dddd, mmmm dd")#</cfif><cfif len(trim(eventRecords[i].EndTime))><cfif NOT len(trim(eventRecords[i].EndDate))>-</cfif> #TimeFormat(eventRecords[i].EndTime, 'h:mm tt')#</cfif><br />
		<span class="miniCalendarEventDisplayHeader">#eventRecords[i].Title#</span><br />
		#eventRecords[i].Location#
		<p />
		#eventRecords[i].Description#
		<p />
		<cfif Len(Trim(eventRecords[i].ContactPhone))>For more information, call #eventRecords[i].ContactPhone#.<br /></cfif>
		<cfif Len(Trim(eventRecords[i].ContactEmail))>Email: <a href="mailto:#eventRecords[i].ContactEmail#">#eventRecords[i].ContactEmail#</a>.</cfif>
		<p />
		<div  style="text-align: center;"><a href="##top">Back to top</a></div>
		<div style="display:none;" class="vevent">
	<span class="dtstamp">#DateFormat(Now(), "yyyy-mm-dd")#T#TimeFormat(Now(), "HH:mm:ss")#</span>
		<span class="summary title">#Trim(eventRecords[i].Title)#</span>
		<a href="http://#cgi.server_name#/#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(Attributes.linkDate)#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="url">Event Link</a>
		<div class="description">#eventRecords[i].Description#</div>
		<span class="dtstart" title="#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#<cfif Len(Trim(eventRecords[i].StartTime))>T#TimeFormat(eventRecords[i].StartTime, "HH:mm:ss")#</cfif>">#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#<cfif Len(Trim(eventRecords[i].StartTime))>T#TimeFormat(eventRecords[i].StartTime, "HH:mm:ss")#</cfif></span>
		<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate AND eventRecords[i].StartTime neq eventRecords[i].EndTime><span class="dtend" title="<cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif><cfif Len(Trim(eventRecords[i].EndTime))>T#TimeFormat(eventRecords[i].EndTime, "HH:mm:ss")#</cfif>"><cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif><cfif Len(Trim(eventRecords[i].EndTime))>T#TimeFormat(eventRecords[i].EndTime, "HH:mm:ss")#</cfif></span></cfif></div>
		</td>
	</tr></cfoutput></cfif></cfloop></table></cfif></cfif>